package com.xzq.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
/**
 * 分类实体类
 * @author Adam
 *
 */
@Entity
public class Type implements Serializable {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer id;
	@Column(length=50,nullable=false)
	private String name;
	@Column(length=255)
	private String note;
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
	@JoinColumn(name="type_id")
	private Set<Type> types = new HashSet<Type>();
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
	@JoinColumn(name="type_id",insertable=true)
	private Set<Product> products = new HashSet<Product>();
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}
	public Set<Type> getTypes() {
		return types;
	}
	public void setTypes(Set<Type> types) {
		this.types = types;
	}
	public Set<Product> getProducts() {
		return products;
	}
	public void setProducts(Set<Product> products) {
		this.products = products;
	}
	public Type() {
		super();
	}
	public Type(Integer id, String name, String note) {
		super();
		this.id = id;
		this.name = name;
		this.note = note;
	}
	public Type(String name, String note) {
		super();
		this.name = name;
		this.note = note;
	}
	
}
